/**
 * Written By: MinHo Kim (minho.kim.korea@gmail.com)
 * Copyright (C) 2011, MinHo Kim, Software Expert Program, KAIST University, Seoul, Korea.
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public License as published 
 * by the Free Software Foundation; version 2 of the License.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.
 */
package kaist.sep502.tsp.algorithm.search;

import kaist.sep502.tsp.algorithm.heuristic.Heuristic;
import kaist.sep502.tsp.algorithm.heuristic.HeuristicAlgorithm;
import kaist.sep502.tsp.model.CityPath;
import kaist.sep502.tsp.model.Problem;
import kaist.sep502.tsp.model.Solution;



/**
 * @author minho kim
 *
 */
public abstract class SearchAlgorithm {
	protected Solution solution;
	protected Problem problem;
	protected HeuristicAlgorithm heuristicAlgorithm;
	
	public SearchAlgorithm(Problem problem){
		this.problem = problem;
		heuristicAlgorithm = new HeuristicAlgorithm() {
			@Override
			public Heuristic getHx(Problem problem, CityPath cityPath) {
				Heuristic heuristic = new Heuristic();
				heuristic.cityNo = problem.departureCityNo;
				heuristic.hx = 0.0;
				return heuristic;
			}

			@Override
			public Heuristic getHx(Problem problem, CityPath cityPath, int nextCityNo) {
				Heuristic heuristic = new Heuristic();
				heuristic.cityNo = nextCityNo;
				heuristic.hx = 0.0;
				return heuristic;
			}

			@Override
			public long getExpandedCount() {
				return 0;
			}
		};
		
	}
	
	/**
	 * @param heuristicAlgorithm the heuristicAlgorithm to set
	 */
	public void setHeuristicAlgorithm(HeuristicAlgorithm heuristicAlgorithm) {
		this.heuristicAlgorithm = heuristicAlgorithm;
	}

	
	public abstract Solution search();

	/**
	 * @return the problem
	 */
	public Problem getProblem() {
		return problem;
	}

	/**
	 * @param problem the problem to set
	 */
	public void setProblem(Problem problem) {
		this.problem = problem;
	}
	
}
